﻿@using System.CodeDom
@using System.CodeDom.Compiler
@using System.Collections
@using System.Collections.Specialized
@using System.Reflection
@using System.Text
@using Newtonsoft.Json
@using Newtonsoft.Json.Linq
@using Newtonsoft.Json.Serialization
@using OF.JsonRpc
@using OF.JsonRpc.AspNet
@using OF.JsonRpc.ExtensionInject
@using OF.JsonRpc.Reflection
@using OF.JsonRpc.Util
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>JSON-RPC Help  - @Request.Params["name"]</title>
    <link href="~/Content/bootstrap.min.css" rel="stylesheet"/>
    <link href="~/Content/styles.css" rel="stylesheet"/>
    <link href="~/Scripts/highlight/styles/vs.css" rel="stylesheet"/>
    <style type="text/css">h4 {margin-top:20px}</style>
</head>
<body>
<nav class="navbar navbar-default" role="banner">
    <div class="container">
        <div class="navbar-header" class="text-center">
            <h2>
                @Html.ActionLink("JSON-RPC Help", "Index")
            </h2>
        </div>
    </div>
</nav>
<div class="container">

    @{
        string typeName = Request.Params["name"];
        try
        {
            var type = Type.GetType(typeName);

            <h2>References code for type: <code>@AssemlbyCommentReader.GetCSharpRepresentation(type)</code></h2>

            <ul class="nav nav-tabs" id="codeTab">
                <li role="presentation" class="active"><a href="#cs">C# Entity</a></li>
                @*<li role="presentation"><a href="#csvm">C# ViewModel</a></li>*@
            </ul>
            <div class="tab-content">
                
                <div role="tabpanel" class="tab-pane active" id="cs">
                    <div style="margin: 7px 0px; text-align:center"><button type="button" class="btn btn-sm btn-primary" data-clipboard-action="copy" data-clipboard-target="#cs">copy</button></div>
                    @{
                        var dict = new CSharpEntityGenerator().GenerateCodeForType(type);
                        foreach (var code in dict)
                        {
                            <pre class="small" style="background-color: #FFFFFF"><code spellcheck="false" class="cs">@code.Value</code></pre>
                        }
                    }
                    <div style="margin: 7px 0px; text-align:center"><button type="button" class="btn btn-sm btn-primary" data-clipboard-action="copy" data-clipboard-target="#cs">copy</button></div>

                </div>
                <div role="tabpanel" class="tab-pane" id="csvm">
                    TODO: View Model Code ...
                </div>

            </div>
            
        }
        catch (Exception ex)
        {
            <p style="font-size: 24px; color: red">
                Sorry, <code>@ex.Message</code>
            </p>
        }
        
    }


</div>
<script src="~/Scripts/jquery.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/highlight/highlight.pack.js"></script>
<script src="~/Scripts/scripts.js"></script>
<script src="~/Scripts/clipboard.min.js"></script>
<script type="text/javascript">
    
    hljs.initHighlightingOnLoad();

    $(function () {
        new Clipboard('.btn');
        //$('#btnCopy').click(function(e) {
        //    var txtObj = document.getElementById('cs');  
        //    if(window.clipboardData){ // 仅IE支持此对象，firefox、chrome不支持  
        //        //1、通过clipboardData对象实现复制  
        //        window.clipboardData.clearData();  
        //        window.clipboardData.setData("Text",txtObj.innerText);  
          
        //        ////2、通过document对象实现复制:先选择中文本，再执行复制命令  
        //        //txtObj.select();  
        //        //document.execCommand("Copy"); // 仅IE支持，Firefox报语法错误，chrome执行结果返回false(不支持)  
          
        //        ////3、通过TextRange对象实现现复制：可以不用先选中内容  
        //        //txtObj.createTextRange().execCommand("Copy");  
        //    }  
        //});

        $('#codeTab a').click(function(e) {
            //e.preventDefault()
            $(this).tab('show');
        });
    });
</script>
    
        
    
</body>
</html>